package cn.ac.siom.query.action;

import cn.ac.siom.query.service.IPatents_infoService;
import cn.ac.siom.query.util.action.DefaultAction;
import cn.ac.siom.query.vo.Patents_info;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.sql.SQLException;
import java.util.List;

@Controller
@RequestMapping(value = "/home/*")
public class Patents_infoAction extends DefaultAction {
    @Resource
    private IPatents_infoService patents_infoService;

    @RequestMapping(value = "patents_info_list")
    public void list(HttpServletResponse response) {
        response.setHeader("Access-Control-Allow-Origin", "*");
        try {
            super.printObjectToList(response, "allPatents_info", this.patents_infoService.list());
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
    @ResponseBody
    @RequestMapping(value="findNO_Patents_info", method= RequestMethod.GET,produces="application/json;charset=UTF-8")
    public List<Patents_info> findNO(Integer i_id) throws SQLException {
        System.out.println(i_id);
        List<Patents_info>  patents_infos = this.patents_infoService.list_NO(i_id);
        for(Patents_info patents_info:patents_infos) {
            System.out.println(patents_info.toString());
        }
        return patents_infos;
    }
    @Override
    public String getText() {
        return null;
    }
}
